package com.erik.ipmonitor.listener;

import cn.hutool.core.bean.BeanUtil;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.erik.ipmonitor.model.excel.ProjectExcel;
import com.erik.ipmonitor.model.po.Project;
import com.erik.ipmonitor.repository.ProjectRepository;

/**
 * 说明信息
 *
 * @author : erik.zhou
 * @date : 2025/08/25/17:13
 * @description :
 */
public class ProjectExcelListener extends AnalysisEventListener<ProjectExcel> {


    private final ProjectRepository projectRepository;


    public ProjectExcelListener(ProjectRepository projectRepository) {
        this.projectRepository = projectRepository;
    }


    @Override
    public void invoke(ProjectExcel data, AnalysisContext context) {
        Project project = BeanUtil.copyProperties(data, Project.class);
        projectRepository.save(project);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {

    }
}
